//
//  Double+Extensions.swift
//  HomeShop
//
//  Created by 刘泽 on 2018/2/11.
//  Copyright © 2018年 刘泽. All rights reserved.
//

import Foundation
import UIKit
extension Double{
    
    public func toString() -> String {
        return String(self)
    }
    
    public func toInt() -> Int {
        if self.isNaN || self.isInfinite{
            return 0
        }else{
            return Int(self)
        }

    }
    public func toCGFloat() -> CGFloat {
        return CGFloat(self)
    }
    public func toFloat() -> Float {
        return Float(self)
    }

    public func decimals(_ count : Int) -> Double{
        return Double(String(format: "%.\(count)f", self)) ?? 0
    }

    
}
